package com.gxa.jd.mapper;

import com.gxa.jd.pojo.Order;
import com.gxa.jd.vo.OrderVo;
import com.gxa.jd.vo.OrderVoo;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface OrderMapper extends Mapper<Order> {


    @Select("SELECT r.order_num as orderNum,h.`name`,h.address,h.phone as phoneHotel,r.check_in_num as checkInTime,r.check_out_time as checkOutTime,r.check_in_num as" +
            " checkInNum,r.reserve_num as reserve_num,r.check_in_person as checkInPerson,r.phone,r.message,r.money,r.payment,r.submission_time as submissionTime," +
            "r.state,r.`mode`,r.last_pay_time as lastPayTime,m.room_name as roomName,m.price,u.id as userId FROM " +
            "room_order r,hotel h,room m,gxa_user u where r.hotel_id=h.id and r.room_id=m.id and r.user_id=u.id AND r.order_num=#{orderNum}; " )
        public OrderVo findOrderVoById(String orderNum);


    @Select("select r.order_num as orderNum,m.room_name as roomName,m.price,r.check_in_num as checkInNum,r.state,r.money FROM room m,room_order r,gxa_user u where r.user_id=u.id and r.room_id=m.id and u.id={id}")
        public List<OrderVoo> findByUserId(Long id);

    @Select("select r.order_num as orderNum,m.room_name as roomName,m.price,r.check_in_num as checkInNum,r.state,r.money FROM room m,room_order r,gxa_user u where r.user_id=u.id and r.room_id=m.id and u.id={id} and state={state}")
     public List<OrderVoo> findByS(Long id,Integer state);



}
